package com.easy.service.impl;

import com.easy.bean.User;
import com.easy.dao.UserDao;
import com.easy.service.IShoppingLoginService;
import com.easy.util.SYS;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class ShoppingLoginService implements IShoppingLoginService {
    @Autowired
    UserDao userDao;
    @Override
    public String dologin(User user) {
        User user_data=userDao.getUserByUsername(user.getUsername());
        if(user_data==null){
            return "false";
        }else{
            if(user_data.getRole().equals("0")){
                return "freeze";
            }else{
                if(SYS.checkPass(user.getPassword(),user_data.getPassword())){
                    user.setPassword(SYS.digest(user.getPassword()));
                    user.setId(user_data.getId());
                    return "true";
                }else{
                    return "false";
                }
            }
        }
    }
}
